
import { handleActions, createAction } from 'redux-actions';
import request from '../utils/request'


var namespace = 'home'

var state = {
    list: [],
    user: {
        name: '',
        age: ''
    },
}
export default {
    // 处理异步
    effects: {
        getUser: createAction('', async (payload) => {        //根据ID获取到推荐职位列表

            return {                                                    //在这返回数据
                user: {
                    name: 10,
                    age: 20
                },
            }
        }),
        getList: createAction(namespace + '/setState', async (payload) => {        //根据ID获取到推荐职位列表

            return {                                                    //在这返回数据
                list: payload.list,
            }
        })
    },
    // 同步更新数据
    reducer: {
        [namespace]: handleActions({

            // 修改基础数据
            [namespace + '/setState']: {
                //成功执行的函数
                next(state, action) {

                    console.log('执行reducer')
                    return {
                        ...state,
                        ...action.payload,
                    };
                },
                //失败后执行的函数
                throw(state, action) {
                    return {
                        ...state
                    };
                }
            },
        }, state),
    }
}


